<?php

namespace app\parking\service;

use think\facade\Db;

class ParkingService
{
    public static function calculateFee($plateNumber)
    {
        // 示例逻辑：根据车牌号计算停车时长及费用
        $parkingInfo = Db::name('parking_parking')->where('plate_number', $plateNumber)->find();
        if (!$parkingInfo) {
            return ['status' => 'error', 'message' => '车辆未找到'];
        }
        
        // 计算停车费用的示例逻辑
        $entryTime = strtotime($parkingInfo['entry_time']);
        $currentTime = time();
        $duration = ($currentTime - $entryTime) / 60; // 以分钟为单位
        $fee = max(0, ($duration - 15) * 0.5); // 假设每分钟0.5元，前15分钟免费
        
        return ['status' => 'success', 'duration' => $duration, 'fee' => $fee];
    }
}
